package com.example.bookstore.controller;

import com.example.bookstore.common.PageResult;
import com.example.bookstore.common.Result;
import com.example.bookstore.dto.AppraiseRequest;
import com.example.bookstore.entity.Appraise;
import com.example.bookstore.service.AppraiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/appraise")
public class AppraiseController {
    @Autowired
    AppraiseService appraiseService;

    @PutMapping
    public Result addAppraise(@RequestBody AppraiseRequest appraiseRequest){
        return appraiseService.addAppraise(appraiseRequest);
    }
    @PostMapping("/page")
    public PageResult<Appraise> getBookAppraise(int pageSize, int currentPage, int bookId){
        return appraiseService.getBookAppraise(pageSize,currentPage,bookId);
    }
    @GetMapping("/byOrder/{id}")
    public Result getAppraiseByOrder(@PathVariable Integer id){
        return appraiseService.getAppraiseByOrder(id);
    }
}
